package com.ssm.car.rpc.service.impl.parking;

import com.github.pagehelper.PageInfo;
import com.ssm.car.dao.mapper.parking.ParkingDao;
import com.ssm.car.dao.mapper.parkinglot.ParkinglotDao;
import com.ssm.car.dao.mapper.parkingzone.ParkingzoneDao;
import com.ssm.car.dao.model.Parking;
import com.ssm.car.rpc.api.parking.ParkingService;
import com.ssm.upms.dao.mapper.ssm.LzDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
* 停车场管理 Service
* @author GaoXiang
* @version 1.0
*/
@Service
public class ParkingServiceImpl extends LzDao<Parking> implements ParkingService{

    @Resource
    private ParkingDao parkingDao;

 /*   @Resource
    private AccountDao accountDao;

    @Resource
    private AccountRoleDao accountRoleDao;*/

    @Resource
    private ParkinglotDao parkinglotDao;
  /*  @Resource
    private LockDao lockDao;*/
    @Resource
    private ParkingzoneDao parkingzoneDao;
/*    @Resource
    private ImageDao imageDao;
    @Resource
    private ParkuseDao parkuseDao;
    @Resource
    private ParkingpayDao parkingpayDao;*/

    /**
    * 保存数据
    * @param parking 实体对象
    * @return 实体id
    * @throws Exception 数据保存异常
    */
    public Integer insert(Parking parking) throws Exception {
        return parkingDao.insert(parking);
    }

    /**
    * 根据 id 修改
    * @param parking 带id的实体对象
    * @return 受影响的行数
    * @throws Exception 数据修改异常
    */
    public Integer updateById(Parking parking) throws Exception {
        return parkingDao.updateById(parking);
    }

    /**
    * 根据 id 删除
     * 2017-6-1 13:48:49 韩榕榕
    * @param id 数据id
    * @return 受影响的行数
    * @throws Exception 数据删除异常
    */
    public Integer deleteById(String id) throws Exception {
    /*  List<Account> accountList= accountDao.selectByInfoId(id);
      if(accountList.size()>0){
          List<String> accountIds=new ArrayList<String>();
          for(Account account:accountList){
              accountIds.add(account.getId());
          }
          accountRoleDao.deleteByAccountIds(accountIds);
          accountDao.deleteByInfoId(id);
      }
       lockDao.deleteByParkingId(id);
       parkingpayDao.deleteByParkingId(id);
       parkuseDao.deleteByParkingId(id);
       parkinglotDao.deleteByParkingId(id);
       parkingzoneDao.deleteByParkingId(id);
       imageDao.deleteByInfoId(id);*/
      return parkingDao.deleteById(id);
    }

    /**
    * 根据 id 查找
    * @param id 实体id
    * @return 实体
    */
    public Parking selectById(String id) {
        return parkingDao.selectById(id);
    }

    public Integer deleteByIds(List<String> ids) throws Exception {
        return null;
    }

    /**
    * 根据 id 批量删除
     * 2017-6-1 13:49:05 韩榕榕
    * @param ids 要删除的id
    * @return 影响的行数
    * @throws Exception 数据删除异常
    */
  /*  public Integer deleteByIds(List<String> ids) throws Exception {
      *//* List<Account> accountList= accountDao.listByInfoIds(ids);
       if(accountList.size()>0){
           List<String> accountIds=new ArrayList<String >();
           for(Account a:accountList){
               accountIds.add(a.getId());
           }
           accountRoleDao.deleteByAccountIds(accountIds);
           accountDao.deleteByInfoIds(ids);
       }
        lockDao.deleteByParkingIds(ids);
        parkuseDao.deleteByParkingIds(ids);
        parkinglotDao.deleteByParkingIds(ids);
        parkingzoneDao.deleteByParkingIds(ids);
        imageDao.deleteByInfoIds(ids);*//*
        return parkingDao.deleteByIds(ids);
    }*/

    /**
    * 查询列表
    * @param map 参数
    * @return 列表
    */
    public PageInfo<Parking> list(Map map) {
        return parkingDao.list(map);
    }

    /**
    * 查询列表 带分页
    * @param map 参数
    * @param page 页码
    * @param size 每页大小
    * @return 列表
    */
    public PageInfo<Parking> list(Map map, int page, int size) {
        return parkingDao.list(map,page,size);
    }


    /**
     * 选择停车场
     * 2017-5-23 14:27:51 韩榕榕
     * @param map 参数
     * @return 集合
     */
    public List<Parking> chooseParking(Map map){return parkingDao.chooseParking(map);}

    /**
     * 停车场列表
     * 2017-5-25 10:13:35 韩榕榕
     * @param map 参数
     * @return 集合
     */
    public List<Parking> listAll(Map map){return  parkingDao.listAll(map);}

    /**
     * 根据区域查询停车场
     * @param parking
     * @return
     */
    public List<Parking> selectByCity(Parking parking){

        return parkingDao.selectByCity(parking);
    }
    public Long countPark(Parking parking){

        return parkingDao.countPark(parking);
    }
    public Long countAutoPark(Parking parking){
        return parkingDao.countAutoPark(parking);
    }
    public Long countOrdinaryPark(Parking parking){

        return parkingDao.countOrdinaryPark(parking);
    }
    public Long countParkTotal(Parking parking){

        return parkingDao.countParkTotal(parking);
    }
    public Long countAutoParkTotal(Parking parking){
        return parkingDao.countAutoParkTotal(parking);
    }
    public Long countOrdinaryParkTotal(Parking parking){

        return parkingDao.countOrdinaryParkTotal(parking);
    }
    public List<Parking> selectByParking(Parking parking){
        return parkingDao.selectByParking(parking);
    }


    /**
     * 保存图片信息
     * @param image 实体对象
     * @return 实体id
     * @throws Exception 数据保存异常
     */
/*
    public Integer insertImg(Image image) throws Exception {
        return parkingDao.insertImg(image);
    }
*/


}
